﻿#pragma once
#include "ChapterManager.g.h"


namespace winrt::NovelReader::implementation
{
	struct ChapterManager : ChapterManagerT<ChapterManager>
	{
		ChapterManager() = default;
		ChapterManager(hstring const& filePath);

		winrt::Windows::Foundation::IAsyncOperation<winrt::NovelReader::ChapterCollection> GetChaptersAsync();
		hstring BookName() const;

	private:
		static bool IsTitle(std::wstring const& line);
		std::wstring GetSqliteFilePath() const; 
		winrt::NovelReader::ChapterCollection GetChaptersFromTextFile() const;

		std::wstring m_filePath; 
		bool m_canLoadFromSqlite{ false }; 
		std::wstring m_sqlFilePath; 
		winrt::NovelReader::ChapterCollection m_collection {nullptr}; 
	};
}

namespace winrt::NovelReader::factory_implementation
{
	struct ChapterManager : ChapterManagerT<ChapterManager, implementation::ChapterManager>
	{
	};
}
